﻿
Public Class frmSetupLocale
    Public m_localeConcourse As New LocaleWeatherDataConcourse
    Private shadow_m_localeConcourse As New LocaleWeatherDataConcourse
    Private m_newLocale As New LocaleWeatherDataConcourse
    Private m_setOption As New LocaleSetOption
    Private m_newOption As New LocaleSetOption
    Private m_countH As Integer = 0
    Private m_countTime As Integer = 0
    Private Sub frmSetupLocale_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.FlexHeight.Styles.Alternate.BackColor = Color.FromArgb(216, 228, 248)
        Me.FlexTime.Styles.Alternate.BackColor = Color.FromArgb(216, 228, 248)


        Dim sdate As New Date
        Dim edate As New Date
        LoadFlexHeight()
        LoadFlexTime()

        'Me.dateTstart.Text = Me.m_localeConcourse.ArrLocaleWeatherData(0).Year & "年" & Me.m_localeConcourse.ArrLocaleWeatherData(0).Month & "月" & Me.m_localeConcourse.ArrLocaleWeatherData(0).Day & "日"
        'Me.dateTend.Text = Me.m_localeConcourse.ArrLocaleWeatherData(sl).Year & "年" & Me.m_localeConcourse.ArrLocaleWeatherData(sl).Month & "月" & Me.m_localeConcourse.ArrLocaleWeatherData(sl).Day & "日"
        If StringHandle.L_openFile = 1 Then
            Dim sl As Integer = Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
            sdate = Me.m_localeConcourse.ArrLocaleWeatherData(0).Year & "年" & Me.m_localeConcourse.ArrLocaleWeatherData(0).Month & "月" & Me.m_localeConcourse.ArrLocaleWeatherData(0).Day & "日"
            edate = Me.m_localeConcourse.ArrLocaleWeatherData(sl).Year & "年" & Me.m_localeConcourse.ArrLocaleWeatherData(sl).Month & "月" & Me.m_localeConcourse.ArrLocaleWeatherData(sl).Day & "日"
            Me.dateTstart.Value = sdate
            Me.dateTend.Value = edate
        Else
            Me.dateTstart.Value = New DateTime(2008, 1, 1)
            Me.dateTend.Value = New DateTime(2008, 12, 31)

        End If

        Me.FlexHeight.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
        Me.FlexHeight.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None
        Me.FlexHeight.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None

        Me.FlexTime.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
        Me.FlexTime.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None
        Me.FlexTime.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
    End Sub
    ''' <summary>
    ''' 还原 高度表格
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadFlexHeight()


        If StringHandle.L_openFile = 1 Then
            'Dim sl As Integer = Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
            'Me.dateTstart.Text = Me.m_localeConcourse.ArrLocaleWeatherData(0).Year & "年" & Me.m_localeConcourse.ArrLocaleWeatherData(0).Month & "月" & Me.m_localeConcourse.ArrLocaleWeatherData(0).Day & "日"
            'Me.dateTend.Text = Me.m_localeConcourse.ArrLocaleWeatherData(sl).Year & "年" & Me.m_localeConcourse.ArrLocaleWeatherData(sl).Month & "月" & Me.m_localeConcourse.ArrLocaleWeatherData(sl).Day & "日"

            '获得高度数组
            For j As Integer = 0 To Me.m_localeConcourse.ArrLocaleWeatherData(0).ArrTierData.Length - 1
                ReDim Preserve Me.m_setOption.Arrheight(j)
                Me.m_setOption.Arrheight(j) = New LocaleHeight
                Me.m_setOption.Arrheight(j).Height = Me.m_localeConcourse.ArrLocaleWeatherData(0).ArrTierData(j).DistanceTerraHeight
            Next


            Me.FlexHeight.Rows.Count = Me.m_setOption.Arrheight.Length + 1
            For i As Integer = 0 To Me.m_setOption.Arrheight.Length - 1
                Me.FlexHeight.SetData(i + 1, 0, i + 1)
                Me.FlexHeight.SetData(i + 1, 1, Me.m_setOption.Arrheight(i).Height)
            Next

            Me.txtH.Text = Me.m_setOption.Arrheight.Length


            For i As Integer = 0 To Me.FlexHeight.Rows.Count - 2
                ReDim Preserve Me.m_newOption.Arrheight(i)
                Me.m_newOption.Arrheight(i) = New LocaleHeight
                m_newOption.Arrheight(i).Height = Me.FlexHeight.GetData(i + 1, 1)
            Next
        Else
            Me.FlexHeight.Rows.Count = 1


        End If
    End Sub
    ''' <summary>
    ''' 还原 时间表格
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadFlexTime()
        Dim dateStart As String = ""

        Dim dateAgency As String = ""
        Dim countT As Integer = 0
        Dim a As Boolean = True
        If StringHandle.L_openFile = 1 Then

            dateStart = Me.m_localeConcourse.ArrLocaleWeatherData(0).Year & Me.m_localeConcourse.ArrLocaleWeatherData(0).Month & Me.m_localeConcourse.ArrLocaleWeatherData(0).Day
            'For i As Integer = 0 To Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
            '    If a = True Then
            For j As Integer = 0 To Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
                dateAgency = Me.m_localeConcourse.ArrLocaleWeatherData(j).Year & Me.m_localeConcourse.ArrLocaleWeatherData(j).Month & Me.m_localeConcourse.ArrLocaleWeatherData(j).Day
                If dateStart = dateAgency Then
                    countT += 1
                Else

                    Exit For
                End If

            Next
            'Else
            '    Exit For
            'End If

            '    Next

            'Dim L As Integer = Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
            'Me.dateTstart.Value = New Date(Me.m_localeConcourse.ArrLocaleWeatherData(0).Year, Me.m_localeConcourse.ArrLocaleWeatherData(0).Month, Me.m_localeConcourse.ArrLocaleWeatherData(0).Day)
            'Me.dateTend.Value = New Date(Me.m_localeConcourse.ArrLocaleWeatherData(L).Year, Me.m_localeConcourse.ArrLocaleWeatherData(L).Month, Me.m_localeConcourse.ArrLocaleWeatherData(L).Day)
            ''获得时间数组
            'For i As Integer = 0 To Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
            '    dateStart = Me.m_localeConcourse.ArrLocaleWeatherData(0).Year & Me.m_localeConcourse.ArrLocaleWeatherData(0).Month & Me.m_localeConcourse.ArrLocaleWeatherData(0).Day
            '    dateAgency = Me.m_localeConcourse.ArrLocaleWeatherData(i + 1).Year & Me.m_localeConcourse.ArrLocaleWeatherData(i + 1).Month & Me.m_localeConcourse.ArrLocaleWeatherData(i + 1).Day

            '    If dateStart = dateAgency Then
            '        countT += 1
            '    Else
            '        Exit For
            '    End If

            'Next
            For i As Integer = 0 To countT - 1
                ReDim Preserve Me.m_setOption.ArrTime(i)
                Me.m_setOption.ArrTime(i) = New LocaleTime
                Me.m_setOption.ArrTime(i).Time = Me.m_localeConcourse.ArrLocaleWeatherData(i).Time
            Next


            Me.FlexTime.Rows.Count = Me.m_setOption.ArrTime.Length + 1
            For i As Integer = 0 To Me.m_setOption.ArrTime.Length - 1
                Me.FlexTime.SetData(i + 1, 0, i + 1)
                Me.FlexTime.SetData(i + 1, 1, Me.m_setOption.ArrTime(i).Time)
            Next
            Me.txtTime.Text = countT


            '
            For i As Integer = 0 To Me.FlexTime.Rows.Count - 2
                ReDim Preserve Me.m_newOption.ArrTime(i)
                Me.m_newOption.ArrTime(i) = New LocaleTime
                Me.m_newOption.ArrTime(i).Time = Me.FlexTime.GetData(i + 1, 1)
            Next
        Else
            Me.FlexTime.Rows.Count = 1
        End If
    End Sub

    Private Sub txtH_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtH.Validating

        Try
            If txtH.Text <> Nothing And txtH.Text <> "" And txtH.Text.Trim() <> "" Then
                If txtH.Text < 1 Then


                    txtH.Text = ""
                    Me.FlexHeight.Rows.Count = 1
                    MessageBox.Show("测试高度最少是一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                Else
                    m_countH = CInt(Me.txtH.Text)
                    Me.FlexHeight.Rows.Count = m_countH + 1
                    For i As Integer = 0 To m_countH - 1
                        Me.FlexHeight.SetData(i + 1, 0, i + 1)
                        ReDim Preserve Me.m_newOption.Arrheight(i)
                        Me.m_newOption.Arrheight(i) = New LocaleHeight
                        m_newOption.Arrheight(i).Height = Me.FlexHeight.GetData(i + 1, 1)
                    Next
                End If

            End If
        Catch ex As Exception
            txtH.Text = ""
            Me.FlexHeight.Rows.Count = 1
            MessageBox.Show("输入不正确，测试高度最少是一次，请输入数字！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End Try



        'If SetHeight(m_countH) = True Then


        'For i As Integer = 0 To Me.m_countH - 1

        'Next
        'End If
    End Sub

    Private Function SetHeight(ByVal count As Integer) As Boolean
        Dim Dia As New DialogResult
        If count < Me.m_setOption.Arrheight.Length Then
            Dia = MessageBox.Show("这样会发生数据丢失，你确定这样做吗？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
            If Dia = Windows.Forms.DialogResult.Yes Then
                Return True
            Else
                LoadFlexHeight()
                Return False

            End If
        Else
            Return True
        End If
    End Function

    Private Sub FlexHeight_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles FlexHeight.Validating
        'Dim fhcount As Integer = 0
        If txtH.Text <> Nothing And txtH.Text <> "" And txtH.Text.Trim() <> "" Then
            If CInt(txtH.Text) > 0 Then
                For i As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                    ReDim Preserve Me.m_newOption.Arrheight(i)
                    Me.m_newOption.Arrheight(i) = New LocaleHeight
                    Me.m_newOption.Arrheight(i).Height = Me.FlexHeight.GetData(i + 1, 1)
                Next
            End If

        End If



        'Dim hrow As Integer = Me.FlexHeight.RowSel
        'For i As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
        '    If Me.FlexHeight.GetData(hrow, 1) < 0 Then
        '        MessageBox.Show("距离不能小于1 米，请改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        '        Exit Sub
        '    End If
        '    If FlexHeight.GetData(hrow, 1) = Me.m_newOption.Arrheight(i).Height Then
        '        Me.FlexHeight.SetData(hrow, 1, Me.m_newOption.ArrTime(hrow - 1).Time)

        '        MessageBox.Show("有两个距离相等，请删除一个距离，或改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        '        Exit Sub
        '    End If
        'Next
        'For i As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
        '    For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
        '        If Me.m_newOption.Arrheight(i).Height = Me.m_newOption.Arrheight(j).Height Then
        '            MessageBox.Show("有两层的高度相等，请改正或删除一层", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        '            Exit Sub
        '        End If
        '    Next
        'Next
        'For i As Integer = 0 To Me.m_setOption.Arrheight.Length - 1
        '    For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
        '        If Me.m_setOption.Arrheight(i).Height = Me.m_newOption.Arrheight(j).Height Then
        '            fhcount += 1
        '        End If
        '    Next
        'Next

        'SetHeight(fhcount)
    End Sub

    Private Sub FlexHeight_AfterEdit(ByVal sender As System.Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles FlexHeight.AfterEdit
        Dim fhcount As Integer = 0
        Dim hrow As Integer = Me.FlexHeight.RowSel
        'For i As Integer = 0 To Me.FlexHeight.Rows.Count - 2
        '    ReDim Preserve Me.m_newOption.Arrheight(i)
        '    Me.m_newOption.Arrheight(i) = New LocaleHeight
        '    Me.m_newOption.Arrheight(i).Height = Me.FlexHeight.GetData(i + 1, 1)
        'Next
        Try
            For i As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                If Me.FlexHeight.GetData(hrow, 1) < 0 Then
                    MessageBox.Show("距离不能小于1 米，请改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                End If
                If i <> hrow - 1 Then
                    If CDbl(FlexHeight.GetData(hrow, 1)) = CDbl(Me.m_newOption.Arrheight(i).Height) Then
                        Me.FlexHeight.SetData(hrow, 1, Me.m_newOption.Arrheight(hrow - 1).Height)

                        MessageBox.Show("有两个距离相等，请删除一个距离，或改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        Exit Sub
                    End If
                End If

            Next
            ' 把新改变的值 赋给 高度数组
            Me.m_newOption.Arrheight(hrow - 1).Height = Me.FlexHeight.GetData(hrow, 1)
        Catch ex As Exception
            Me.FlexHeight.SetData(hrow, 1, 0)
        End Try


        'Dim row As Integer = 0
        'Dim col As Integer = 0
        'row = Me.FlexHeight.RowSel
        'col = Me.FlexHeight.ColSel
        'Me.m_newOption.Arrheight(row - 1).Height = Me.FlexHeight.GetData(row, col)
    End Sub

    Private Sub txtTime_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtTime.Validating
        Try
            If txtTime.Text <> Nothing And txtTime.Text <> "" And txtTime.Text.Trim() <> "" Then
                If txtTime.Text < 1 Then

                    txtTime.Text = ""
                    Me.FlexTime.Rows.Count = 1
                    MessageBox.Show("测试时间最少是一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                ElseIf txtTime.Text > 24 Then
                    txtTime.Text = 24
                    Me.FlexTime.Rows.Count = 25
                    Me.m_countTime = CInt(txtTime.Text)
                    Me.FlexTime.Rows.Count = m_countTime + 1
                    For i As Integer = 0 To m_countTime - 1 ' Me.FlexTime.Rows.Count - 2
                        FlexTime.SetData(i + 1, 0, i + 1)
                        ReDim Preserve Me.m_newOption.ArrTime(i)
                        Me.m_newOption.ArrTime(i) = New LocaleTime
                        Me.m_newOption.ArrTime(i).Time = Me.FlexTime.GetData(i + 1, 1)
                    Next
                    MessageBox.Show("测试时间最多是24次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)

                Else
                    Me.m_countTime = CInt(txtTime.Text)
                    Me.FlexTime.Rows.Count = m_countTime + 1
                    For i As Integer = 0 To m_countTime - 1 ' Me.FlexTime.Rows.Count - 2
                        FlexTime.SetData(i + 1, 0, i + 1)
                        ReDim Preserve Me.m_newOption.ArrTime(i)
                        Me.m_newOption.ArrTime(i) = New LocaleTime
                        Me.m_newOption.ArrTime(i).Time = Me.FlexTime.GetData(i + 1, 1)
                    Next
                End If

            End If
        Catch ex As Exception
            txtTime.Text = ""
            Me.FlexTime.Rows.Count = 1
            MessageBox.Show("输入不正确，请重新输入数字，测试时间最少是一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End Try


        'If SetTime(m_countTime) = True Then


        'End If


    End Sub
    ''' <summary>
    ''' 设置时间表格
    ''' </summary>
    ''' <param name="count"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function SetTime(ByVal count As Integer) As Boolean
        Dim Dia As New DialogResult
        If count < Me.m_setOption.ArrTime.Length Then
            Dia = MessageBox.Show("这样会造成原先数据的丢失，你确定这样吗？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
            If Dia = Windows.Forms.DialogResult.No Then
                Me.LoadFlexTime()
                Return False
            Else
                Return True
            End If
        Else
            Return True
        End If
    End Function
    ''' <summary>
    ''' 当表格中的值发生改变后
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub FlexTime_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles FlexTime.Validating
        Dim ftCount As Integer = 0
        If txtTime.Text <> Nothing And txtTime.Text <> "" And txtTime.Text.Trim() <> "" Then
            If CInt(txtTime.Text) > 0 Then
                For i As Integer = 0 To m_countTime - 1 ' Me.FlexTime.Rows.Count - 2
                    'If Me.FlexTime.GetData(i + 1, 1) < 0 Or Me.FlexTime.GetData(i + 1, 1) > 24 Then
                    '    MessageBox.Show("时间应该在 1 点 - 24 点 之间", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    '    Exit Sub
                    'End If
                    ReDim Preserve Me.m_newOption.ArrTime(i)
                    Me.m_newOption.ArrTime(i) = New LocaleTime
                    Me.m_newOption.ArrTime(i).Time = Me.FlexTime.GetData(i + 1, 1)
                Next
            End If

        End If





        'For i As Integer = 0 To Me.m_setOption.ArrTime.Length - 1
        '    For j As Integer = 0 To Me.m_newOption.ArrTime.Length - 1
        '        If Me.m_setOption.ArrTime(i).Time = Me.m_newOption.ArrTime(j).Time Then
        '            ftCount += 1

        '        End If
        '    Next
        'Next
        'SetTime(ftCount)
    End Sub

    Private Sub FlexTime_AfterEdit(ByVal sender As System.Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles FlexTime.AfterEdit
        Dim ci As Integer = 0
        Dim frow As Integer = 0
        frow = Me.FlexTime.RowSel


        Try
            If FlexTime.GetData(frow, 1) < 1 Or FlexTime.GetData(frow, 1) > 24 Then
                Me.FlexTime.SetData(frow, 1, Me.m_newOption.ArrTime(frow - 1).Time)
                MessageBox.Show("时间应该在 1 点 - 24 点 之间", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If

            For i As Integer = 0 To Me.FlexTime.Rows.Count - 2 ' Me.m_newOption.ArrTime.Length - 1
                If i <> frow - 1 Then
                    If FlexTime.GetData(i + 1, 1) = FlexTime.GetData(frow, 1) Then
                        'Dim a As Integer = Me.FlexTime.GetData(i + 1, 1)
                        Me.FlexTime.SetData(frow, 1, Me.m_newOption.ArrTime(frow - 1).Time)
                        MessageBox.Show("有两个时间相等，请删除一个时间，或改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        Exit Sub
                    End If
                End If

            Next
            '把改变的值 赋给 时间数组
            Me.m_newOption.ArrTime(frow - 1).Time = Me.FlexTime.GetData(frow, 1)
        Catch ex As Exception
            Me.FlexTime.SetData(frow, 1, 0)
        End Try

        'Me.m_newOption.ArrTime(frow - 1).Time = Me.FlexTime.GetData(frow, 1)
        'For i As Integer = 0 To Me.m_newOption.ArrTime.Length - 1 ' Me.FlexTime.Rows.Count - 2
        '    If CInt(Me.FlexTime.GetData(i + 1, 1)) < 1 Or CInt(Me.FlexTime.GetData(i + 1, 1)) > 24 Then
        '        Dim a As Integer = Me.FlexTime.GetData(i + 1, 1)
        '        Me.FlexTime.SetData(frow, 1, Me.m_newOption.ArrTime(frow - 1).Time)
        '        MessageBox.Show("时间应该在 1 点 - 24 点 之间", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        '        Exit Sub
        '    End If
        'Next
        'For i As Integer = 0 To Me.m_setOption.ArrTime.Length - 1
        '    For j As Integer = 0 To Me.m_newOption.ArrTime.Length - 1
        '        If Me.m_setOption.ArrTime(i).Time = Me.m_newOption.ArrTime(j).Time Then
        '            ci += 1
        '            If ci > 1 Then
        '                Me.FlexTime.SetData(frow, 1, Me.m_setOption.ArrTime(frow - 1).Time)

        '                MessageBox.Show("有两个时间相等，请删除一个时间，或改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        '                Exit Sub
        '            End If

        '        End If
        '    Next
        'Next

        'For i As Integer = 0 To Me.m_newOption.ArrTime.Length - 1 ' Me.m_newOption.ArrTime.Length - 1
        '    If Me.FlexTime.GetData(frow, 1) = Me.m_newOption.ArrTime(i).Time Then
        '        Me.FlexTime.SetData(frow, 1, Me.m_newOption.ArrTime(frow - 1).Time)

        '        MessageBox.Show("有两个时间相等，请删除一个时间，或改正", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        '        Exit Sub
        '    End If
        'Next

    End Sub

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        Dim olddate As String = ""
        Dim oldH As String = ""
        Dim newH As String = ""
        Dim newdate As String = ""
        Dim nMonth As String = ""
        Dim nDay As String = ""
        Dim nTime As String = ""
        Dim tStart As DateTime = Me.dateTstart.Value
        Dim tEnd As DateTime = Me.dateTend.Value
        Dim countDay As Integer = 0
        Dim tempT As Integer = 0
        Dim tempH As String = ""
        Dim coun As Integer = 0
        Dim tL As Integer = 0
        Dim hclew As String = ""
        Dim tclew As String = ""
        If Me.FlexHeight.Rows.Count > 1 Then
            For i As Integer = 0 To Me.FlexHeight.Rows.Count - 2
                If CDbl(FlexHeight.GetData(i + 1, 1)) < 1 Then
                    hclew = "高度表格第" & i + 1 & "行数据，必须大于一米！"
                    MessageBox.Show(hclew, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                End If

            Next


        End If
        If Me.FlexTime.Rows.Count > 1 Then
            For i As Integer = 0 To Me.FlexTime.Rows.Count - 2
                If CInt(FlexTime.GetData(i + 1, 1)) < 1 Then
                    tclew = "时间表格第" & i + 1 & "行，有错误，时间必须为1 - 24 时"
                    MessageBox.Show(tclew, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                End If

            Next
        End If



        If txtH.Text = Nothing Or txtH.Text = "" Or txtH.Text.Trim() = "" Then
            MessageBox.Show("高度最少测试一次！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub

        ElseIf txtTime.Text = Nothing Or txtTime.Text = "" Or txtTime.Text.Trim() = "" Then
            MessageBox.Show("时间最少测试一次！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub


        End If

        If StringHandle.L_openFile = 1 Then
            If CInt(txtH.Text) > 0 Then
                For i As Integer = 0 To Me.m_setOption.Arrheight.Length - 1
                    For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                        If Me.m_setOption.Arrheight(i).Height = Me.m_newOption.Arrheight(j).Height Then
                            coun += 1
                        End If
                    Next
                Next
                If SetHeight(coun) = False Then
                    Exit Sub
                End If



                If CInt(txtTime.Text) > 0 Then
                    coun = 0

                    For i As Integer = 0 To Me.m_setOption.ArrTime.Length - 1
                        For j As Integer = 0 To Me.m_newOption.ArrTime.Length - 1
                            If Me.m_setOption.ArrTime(i).Time = Me.m_newOption.ArrTime(j).Time Then
                                coun += 1
                            End If
                        Next
                    Next

                    If SetTime(coun) = False Then
                        Exit Sub
                    End If

                End If
            End If

        End If
        If txtH.Text <> Nothing And txtH.Text <> "" And txtH.Text.Trim() <> "" Then

            If CInt(txtH.Text) > 0 Then

                ' 高度数组排序
                For i As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                    For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 2
                        If CDbl(Me.m_newOption.Arrheight(j).Height) > CDbl(Me.m_newOption.Arrheight(j + 1).Height) Then
                            tempH = Me.m_newOption.Arrheight(j + 1).Height
                            Me.m_newOption.Arrheight(j + 1).Height = Me.m_newOption.Arrheight(j).Height
                            Me.m_newOption.Arrheight(j).Height = tempH

                        End If
                    Next
                Next
            End If

        End If

        If txtTime.Text <> Nothing And txtTime.Text <> "" And txtTime.Text.Trim() <> "" Then
            If CInt(txtTime.Text) > 0 Then
                '时间数组排序
                For i As Integer = 0 To Me.m_newOption.ArrTime.Length - 1
                    For j As Integer = 0 To Me.m_newOption.ArrTime.Length - 2
                        If Me.m_newOption.ArrTime(j).Time > Me.m_newOption.ArrTime(j + 1).Time Then
                            tempT = Me.m_newOption.ArrTime(j + 1).Time
                            Me.m_newOption.ArrTime(j + 1).Time = Me.m_newOption.ArrTime(j).Time
                            Me.m_newOption.ArrTime(j).Time = tempT

                        End If

                    Next
                Next
            End If

        End If

        'Else
        'MessageBox.Show("请填写下时间！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        'Exit Sub

        'End If







        If tEnd < tStart Then
            MessageBox.Show("结束日期不能小于开始日期，请改正！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
            'ElseIf tEnd = tStart Then

            '    For i As Integer = 0 To Me.m_newOption.ArrTime.Length - 1
            '        ReDim Preserve Me.m_newLocale.ArrLocaleWeatherData(i)
            '        Me.m_newLocale.ArrLocaleWeatherData(i) = New LocaleWeatherData
            '        Me.m_newLocale.ArrLocaleWeatherData(i).Year = tStart.Year
            '        Me.m_newLocale.ArrLocaleWeatherData(i).Month = tStart.Month
            '        Me.m_newLocale.ArrLocaleWeatherData(i).Day = tStart.Day
            '        Me.m_newLocale.ArrLocaleWeatherData(i).Time = Me.m_newOption.ArrTime(i).Time
            '        For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
            '            ReDim Preserve Me.m_newLocale.ArrLocaleWeatherData(j).ArrTierData(j)
            '            Me.m_newLocale.ArrLocaleWeatherData(i).ArrTierData(j) = New LocaleWeatherTierData
            '            Me.m_newLocale.ArrLocaleWeatherData(i).ArrTierData(j).DistanceTerraHeight = Me.m_newOption.Arrheight(j).Height
            '        Next
            '    Next
            'ElseIf tEnd >= tStart Then

        Else
            tL = Me.m_newOption.ArrTime.Length
            Dim nn As Integer = 0
            While tStart.AddDays(countDay) <= tEnd

                For i As Integer = 0 To Me.m_newOption.ArrTime.Length - 1
                    ReDim Preserve Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay)
                    Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay) = New LocaleWeatherData
                    'ReDim Preserve Me.m_newLocale.ArrLocaleWeatherData(i + countDay)
                    'Me.m_newLocale.ArrLocaleWeatherData(i + countDay) = New LocaleWeatherData
                    If tStart.AddDays(countDay).Month < 10 Then
                        nMonth = "0" & tStart.AddDays(countDay).Month
                    Else
                        nMonth = tStart.AddDays(countDay).Month
                    End If

                    If tStart.AddDays(countDay).Day < 10 Then
                        nDay = "0" & tStart.AddDays(countDay).Day
                    Else
                        nDay = tStart.AddDays(countDay).Day
                    End If

                    If Me.m_newOption.ArrTime(i).Time < 10 Then
                        nTime = "0" & Me.m_newOption.ArrTime(i).Time
                    Else
                        nTime = Me.m_newOption.ArrTime(i).Time
                    End If
                    Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).Year = tStart.AddDays(countDay).Year
                    Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).Month = nMonth
                    Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).Day = nDay
                    Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).Time = nTime
                    For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                        ReDim Preserve Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).ArrTierData(j)
                        Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).ArrTierData(j) = New LocaleWeatherTierData
                        Me.m_newLocale.ArrLocaleWeatherData(i + tL * countDay).ArrTierData(j).DistanceTerraHeight = Me.m_newOption.Arrheight(j).Height
                    Next
                    'Me.m_newLocale.ArrLocaleWeatherData(i + countDay).Year = tStart.AddDays(countDay).Year
                    'Me.m_newLocale.ArrLocaleWeatherData(i + countDay).Month = nMonth
                    'Me.m_newLocale.ArrLocaleWeatherData(i + countDay).Day = nDay
                    'Me.m_newLocale.ArrLocaleWeatherData(i + countDay).Time = nTime
                    'For j As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                    '    ReDim Preserve Me.m_newLocale.ArrLocaleWeatherData(i + countDay).ArrTierData(j)
                    '    Me.m_newLocale.ArrLocaleWeatherData(i + countDay).ArrTierData(j) = New LocaleWeatherTierData
                    '    Me.m_newLocale.ArrLocaleWeatherData(i + countDay).ArrTierData(j).DistanceTerraHeight = Me.m_newOption.Arrheight(j).Height
                    'Next

                Next
                countDay += 1
                'Dim a As Date = tStart.AddDays(countDay)
            End While
            'MessageBox.Show(countDay)
            Dim DatesYear As String = tStart.Year
            Dim DatesMonth As String = ""
            Dim DatesDay As String = ""
            Dim DateeYear As String = tEnd.Year
            Dim DateeMonth As String = ""
            Dim DateeDay As String = ""
            If tStart.Month < 10 Then
                DatesMonth = "0" & tStart.Month
            Else
                DatesMonth = tStart.Month
            End If

            If tStart.Day < 10 Then
                DatesDay = "0" & tStart.Day
            Else
                DatesDay = tStart.Day
            End If

            If tEnd.Month < 10 Then
                DateeMonth = "0" & tEnd.Month
            Else
                DateeMonth = tEnd.Month
            End If

            If tEnd.Day < 10 Then
                DateeDay = "0" & tEnd.Day
            Else
                DateeDay = tEnd.Day
            End If
            Dim sdatetime As String = ""
            Dim edatetime As String = ""
            sdatetime = DatesYear & DatesMonth & DatesDay
            edatetime = DateeYear & DateeMonth & DateeDay
            Dim oDate As String = ""

            If StringHandle.L_openFile = 1 Then
                For i As Integer = 0 To Me.m_localeConcourse.ArrLocaleWeatherData.Length - 1
                    For o As Integer = 0 To Me.m_localeConcourse.ArrLocaleWeatherData(i).ArrTierData.Length - 1
                        oDate = Me.m_localeConcourse.ArrLocaleWeatherData(i).Year & Me.m_localeConcourse.ArrLocaleWeatherData(i).Month & Me.m_localeConcourse.ArrLocaleWeatherData(i).Day
                        If oDate >= sdatetime And oDate <= edatetime Then
                            oldH = Me.m_localeConcourse.ArrLocaleWeatherData(i).ArrTierData(o).DistanceTerraHeight
                            olddate = Me.m_localeConcourse.ArrLocaleWeatherData(i).Year & Me.m_localeConcourse.ArrLocaleWeatherData(i).Month & Me.m_localeConcourse.ArrLocaleWeatherData(i).Day & Me.m_localeConcourse.ArrLocaleWeatherData(i).Time & oldH

                            For j As Integer = 0 To Me.m_newLocale.ArrLocaleWeatherData.Length - 1
                                For n As Integer = 0 To Me.m_newOption.Arrheight.Length - 1
                                    newH = Me.m_newOption.Arrheight(n).Height
                                    newdate = Me.m_newLocale.ArrLocaleWeatherData(j).Year & Me.m_newLocale.ArrLocaleWeatherData(j).Month & Me.m_newLocale.ArrLocaleWeatherData(j).Day & Me.m_newLocale.ArrLocaleWeatherData(j).Time & newH

                                    If olddate = newdate Then
                                        Me.m_newLocale.ArrLocaleWeatherData(j).ArrTierData(n) = Me.m_localeConcourse.ArrLocaleWeatherData(i).ArrTierData(o)
                                    End If
                                Next

                            Next
                        End If

                    Next

                Next
                Me.m_localeConcourse = Me.m_newLocale
            Else
                Me.m_localeConcourse = Me.m_newLocale
            End If
        End If


        Me.m_localeConcourse = Me.m_newLocale


        StringHandle.L_openFile = 1
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        StringHandle.L_openFile = 0
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub
End Class